/*输出日志类
  Create At 2017-12-20
*/
var appConsole=function(){
    this.level=["normal","warring","debug","error"];
  
    var color={
      green:"#1ada79",
      orange:"#f77b29",
      blue:"#3eb0f2",
      red:"#f03232"
    };

    this.consoleList={
      "normal": function (text,obj){
        console.log("%c 【一般信息】:" + text,"color:"+color.green, obj);
      },
      "warring": function (text, obj){
        console.log("%c 【警告信息】:" + text, "color:" + color.orange, obj);
      },
      "debug": function (text, obj){
        console.log("%c 【调试信息】:" + text, "color:" + color.blue, obj);
      },
      "error": function (text, obj){
        console.log("%c 【报错信息】:" + text, "color:" + color.red, obj);
      }
    }

    this.debug=true;
    this.filter=-1;
}

appConsole.prototype.setDebug=function(status){
  this.debug=status;
}

appConsole.prototype.setFilter=function(status){
  this.filter=status;
}

appConsole.prototype.log=function(obj,level){
  if(level>this.level.length-1){
    level=2;
  }
  if(this.debug==false){
    return;
  }
  if (this.filter > 0 && this.level != this.filter){
    return;
  }
  var levelStr=this.level[level];
  if(levelStr==undefined){
    levelStr = this.level[2];
  }
  var log_text="";
  var log_obj = obj;

  if(typeof(obj)==="string"){
    log_text = obj;
    log_obj="";
  }

  this.consoleList[levelStr](log_text, log_obj);
}




module.exports.appConsole = new appConsole();






